package edu.fim.data;

import java.sql.SQLException;

import javax.sql.DataSource;

import com.mysql.jdbc.jdbc2.optional.MysqlDataSource;


public class DataSourceFactory {

	public static DataSource createDataSource(
			DatabaseSettings dbSettings,
			String user,
			String password) {
		MysqlDataSource dataSource = new MysqlDataSource();
		dataSource.setUrl(dbSettings.buildUrl());
		dataSource.setUser(user);
		dataSource.setPassword(password);
		try {
			dataSource.getConnection().setAutoCommit(false);
		}
		catch (SQLException e) {
			e.printStackTrace();
		}
		return dataSource;
	}
}